{% extends "blog/blog_base.html" %}

{% block blog_content %}

    <div class="main">

        <!-- Messages  -->
        {% if messages %}
        <ul class="messages">
            {% for message in messages %}
            <li{% if message.tags %} class="{{ message.tags }}"{% endif %}>{{ message }}</li>
            {% endfor %}
        </ul>
        {% endif %}

        <!-- Post  -->
        <ul>
            <div class="blogItemWrapper">
                <div class="blogTitleBar">
                </div>
                <div class="blogTitle">{{ post.title }}</div>
                <div class="blogTime">{{ post.created }}</div>
                <div class="blogItem">   
                    <div class="blogBody">{{ post.body|removetags:""|safe }}</div>
                       
                </div>
            </div>

            <!-- Comments  -->
            {% if comments %}
                <p id="cmttitle">Comments:</p>
            {% endif %}

            <form action="{% url xcheng.views.v_blog_delete_comment post.pk %}" method="POST">{% csrf_token %}
            {% for comment in comments %}
                <div class="blogComment">
                   
                    <span class="blogCommentTime">{{ comment.created }}</span> 
                    <span class="blogCommentAuthor">by {{ comment.author }}</span>
                    
                    <div class="blogCommentBody">{{ comment.body|linebreaks }}</div>
                    {% if user.is_staff %}
                        <input type="checkbox" name="delete" value="{{ comment.pk }}">
                        <a class='transition button small' href="{% url xcheng.views.v_blog_delete_comment post.pk comment.id %}">delete</a>
                    {% endif %}
                </div>
            {% endfor %}

            {% if user.is_staff and comments %}
                <p><input type="submit" value="Delete all selected"></p>
                <br />
            {% endif %}
            </form>

            <div id="addc">Add a comment</div>
            <!-- Comment form  -->
            <form action="{% url xcheng.views.v_blog_add_comment post.id %}" method="POST">{% csrf_token %}
                <div id="cform">
                    <div class="commentSpace"></div>
                    <div class="commentName">
                        <span id="cntxt">Name:</span>
                        <span id="cncnt">{{ form.author }}</span>
                    </div>
                    <div class="commentConetent">
                        <span id="cctxt">Comment: </span>
                        <span id="cccnt">{{ form.body }}</span>
                    </div>
                    <div id="submit"><input class="button big transition" type="submit" value="Submit"></div>
                </div>
                
            </form>
        </ul>

    </div>

{% endblock %}

